﻿using System;
using Ninject;
using Ninject.Activation;
using Ninject.Extensions.Conventions;

namespace SportStore.Core.IoC
{
    /// <summary>
    /// Binding generator based on binding directly to a class.
    /// </summary>
    public class SelfBinder : IBindingGenerator
    {
        #region Public Methods

        /// <summary>
        /// Processes the specified type creating kernel bindings.
        /// </summary>
        public void Process(Type type, Func<IContext, object> scopeCallback, IKernel kernel)
        {
            if (type.IsInterface || type.IsAbstract)
            {
                return;
            }

            kernel.Bind(type).To(type).InScope(scopeCallback);
        }

        #endregion
    }
}
